﻿using System.Windows.Forms;

namespace Tank90
{
    public partial class frmProgressBar : Form
    {
        private int _nowValue;
        private int _totalValue;

        public frmProgressBar()
        {
            InitializeComponent();
            CheckForIllegalCrossThreadCalls = false;
        }

        public int totalValue
        {
            get { return _totalValue; }
            set
            {
                _totalValue = value;
                SetMaxValue(value);
            }
        }

        public int nowValue
        {
            get { return _nowValue; }
            set
            {
                _nowValue = value;
                SetNowValue(value);
            }
        }

        private void SetMaxValue(int totalValue)
        {
            progressBar1.Maximum = totalValue;
        }

        private void SetNowValue(int nowValue)
        {
            progressBar1.Value = nowValue;
            label2.Text = "正在处理第" + nowValue + "个\n";
            label2.Text += "共有121个/" + "剩余" + (121 - nowValue) + "个";
            if (nowValue == _totalValue)
            {
                label1.Text = "正在保存....";
                Close();
            }
        }
    }
}